package com.jiuyin.dianjing.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.jiuyin.dianjing.R;
import com.jiuyin.dianjing.entity.MySection;
import com.jiuyin.dianjing.model.UniversityClub;
import com.jiuyin.dianjing.util.DisplayUtil;

import org.jetbrains.annotations.NotNull;

import java.util.List;

public abstract class SectionQuickAdapter extends BaseSectionQuickAdapter<MySection, BaseViewHolder> {
    Context mContext;

    /**
     * 构造方法里， super()必须设置 header layout
     * data可有可无
     */
    public SectionQuickAdapter(Context context, int layoutResId, int sectionHeadResId, List<MySection> data) {
        super(sectionHeadResId, data);
        mContext = context;
        // 设置普通item布局（如果item类型只有一种，使用此方法）
        setNormalLayout(layoutResId);
        // 注册需要点击的子view id
//        addChildClickViewIds(R.id.more);
    }

    /**
     * 设置header数据
     */
    @Override
    protected void convertHeader(@NotNull BaseViewHolder helper, @NotNull MySection item) {
        if (item.getObject() instanceof String) {
            helper.setText(R.id.tv_header, (String) item.getObject());
        } else {
            TextView tvHeader = helper.itemView.findViewById(R.id.tv_header);
            tvHeader.setText("");
            tvHeader.setCompoundDrawables(null, null, null, null);
            tvHeader.setBackgroundResource(R.color.colorBgGray);
            tvHeader.setHeight(DisplayUtil.dp2px(mContext, 5.7f));
        }
    }

    protected abstract void convert(@NotNull BaseViewHolder helper, MySection item);

}